package net.techwatch.jpa.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class Employee extends Person {
	
	private String phoneExt;
	private Date hireDate;
	private Department department;
	private Job job;
	private SalaryHistory salaryHistory;
	
	public Employee() {
		super();
	}

	/**
	 * @return the phoneExt
	 */
	@Column(name="PHONE_EXT", nullable=false)
	public String getPhoneExt() {
		return phoneExt;
	}

	/**
	 * @param phoneExt the phoneExt to set
	 */
	public void setPhoneExt(String phoneExt) {
		this.phoneExt = phoneExt;
	}

	/**
	 * @return the hireDate
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="HIRE_DATE", nullable=false)
	public Date getHireDate() {
		return hireDate;
	}

	/**
	 * @param hireDate the hireDate to set
	 */
	public void setHireDate(Date hireDate) {
		this.hireDate = hireDate;
	}

	/**
	 * @return the departmentNo
	 */
	@ManyToOne
	public Department getDepartment() {
		return department;
	}

	/**
	 * @param departmentNo the departmentNo to set
	 */
	public void setDepartment(Department department) {
		this.department = department;
	}

	/**
	 * @return the jobCode
	 */
	@OneToOne
	@JoinColumn(name="JOB", nullable=false, referencedColumnName="JOB_ID")
	public Job getJob() {
		return job;
	}

	/**
	 * @param jobCode the jobCode to set
	 */
	public void setJob(Job job) {
		this.job = job;
	}

	/**
	 * @return the salaryHistory
	 */
	@OneToOne(cascade={CascadeType.MERGE, CascadeType.REMOVE}, fetch=FetchType.LAZY)
	@JoinColumn(name="SALARY_HISTORY", referencedColumnName="SALARY_HISTORY_ID")
	public SalaryHistory getSalaryHistory() {
		return salaryHistory;
	}

	/**
	 * @param salaryHistory the salaryHistory to set
	 */
	public void setSalaryHistory(SalaryHistory salaryHistory) {
		this.salaryHistory = salaryHistory;
	}
}
